﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyMES.Domain.zyy;
using MyMES.Error;
using MyMES.Read.API.Application.Command.Roles;

namespace MyMES.Read.API.Controllers.ZYY.Roles
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoleController : ControllerBase
    {
        private readonly IMediator med;

        /// <summary>
        /// 角色显示
        /// </summary>
        /// <param name="med"></param>
        public RoleController(IMediator med)
        {
            this.med = med;
        }
        /// <summary>
        /// 角色
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Role>>> GetRole([FromQuery] GetRolecommand request, CancellationToken cancellationToken)
        {
            try
            {
                return await med.Send(request, cancellationToken);
            }
            catch (Exception)
            {

                throw;
            }
       
        }
    }
}
